let gulp = require('gulp');
let mocha = require('gulp-mocha');
let env = require('gulp-env');

require('../gulp/gulp-base');

// gulp.task('set-dev-node-env', function () {
//     return process.env.NODE_ENV = 'development';
// });
//
//
// gulp.task('set-prod-node-env', function () {
//     return process.env.NODE_ENV = 'production';
// });
//
// gulp.task('set-test-node-env', function (cb) {
//     process.env.NODE_ENV = 'test';
//     process.env.NODE_CONFIG_DIR = '../../config'
//     require('./../../init/properties.js');
//     require('should');
//     require('./../../env');
//     cb();
// });


gulp.task('bookAdd', ['set-test-node-env'], function () {

    return gulp.src([
        './book.add.test.js'
    ]).pipe(mocha()).on('error', function (err) {
        process.exit(1);
    }).on('end', function () {
        process.exit(0);
    });
});

gulp.task('bookDelete', ['set-test-node-env'], function () {

    return gulp.src([
        './book.delete.test.js'
    ]).pipe(mocha()).on('error', function (err) {
        process.exit(1);
    }).on('end', function () {
        process.exit(0);
    });
});

gulp.task('bookUpdate', ['set-test-node-env'], function () {

    return gulp.src([
        './book.update.test.js'
    ]).pipe(mocha()).on('error', function (err) {
        process.exit(1);
    }).on('end', function () {
        process.exit(0);
    });
});
gulp.task('bookGet', ['set-test-node-env'], function () {

    return gulp.src([
        './book.get.test.js'
    ]).pipe(mocha()).on('error', function (err) {
        process.exit(1);
    }).on('end', function () {
        process.exit(0);
    });
});
gulp.task('bookList', ['set-test-node-env'], function () {

    return gulp.src([
        './book.list.test.js'
    ]).pipe(mocha()).on('error', function (err) {
        process.exit(1);
    }).on('end', function () {
        process.exit(0);
    });
});
gulp.task('bookNameList', ['set-test-node-env'], function () {

    return gulp.src([
        './book.list.name.test.js'
    ]).pipe(mocha()).on('error', function (err) {
        process.exit(1);
    }).on('end', function () {
        process.exit(0);
    });
});
gulp.task('bookGetISBNGet', ['set-test-node-env'], function () {

    return gulp.src([
        './book.get.isbn.test.js'
    ]).pipe(mocha()).on('error', function (err) {
        process.exit(1);
    }).on('end', function () {
        process.exit(0);
    });
});


